package test3_14.AccountAndCustomer;

public class Account {

    /*
    写一个名为Account的类模拟账户。该类的属性和方法如下图所示。该类包括的属性：
    账号id，余额balance，年利率annualInterestRate；
     */

    int id;
    double balance;
    double annualInterestRate;

    public Account(int id, double balance, double annualInterestRate) {
        this.id = id;
        this.balance = balance;
        this.annualInterestRate = annualInterestRate;
    }

    //访问器方法（getter和setter方法）
    public int getId() {
        return id;
    }

    public double getBalance() {
        return balance;
    }

    public double getAnnualInterestRate() {
        return annualInterestRate;
    }

    public void setId(int id) {
        this.id = id;
    }

    //
    public void setBalance(double balance) {
        this.balance = balance;
    }

    public void setAnnualInterestRate(double annualInterestRate) {
        this.annualInterestRate = annualInterestRate;
    }

    //在提款方法withdraw中，需要判断用户余额是否能够满足提款数额的要求，如果不能，应给出提示。
    //取款方法withdraw()
    public void withdraw(double amount) {
        if (amount > balance) {
            System.out.println("余额不足");
        } else {
            balance = balance - amount;
            System.out.println("取款成功");
        }
    }

    //存款方法deposit()
    public void deposit(double amount) {
        balance = balance + amount;
        System.out.println("存款成功，余额为：" + balance);
    }
}
